'''
Created on Jul 2, 2014

@author: LONG HOANG GIANG
'''
import py_compile
import os
import glob


def compileLib():
    path = os.path.join(os.path.dirname(__file__), 'lib')
    files = glob.glob('{0}/*py'.format(path))
    for pyfile in files:
        py_compile.compile(pyfile)

def compileCrawlerFile(filename):
    path = 'crawler/{0}'.format(filename)
    py_compile.compile(path)
    
def pycCompiled(path):
    if os.path.isfile(path):
        py_compile.compile(path)
    elif os.path.isdir(path):
        files = glob.glob('{0}/*py'.format(path))
        for subpath in files:
            pycCompiled(subpath)
    

if __name__ == '__main__':
    
    path = raw_input("Enter path: ")
    if not os.path.exists(path):
        print 'Input path not exists'
    else:
        pycCompiled(path)
        print '> Compiled'

    os._exit(1)